
//--------------------------------------------------------------------------------------
// register the function
var newRegistery1 = new Array("getPricesHistory", "drawPricesHistoryChart" );
allJsonsRegistry = allJsonsRegistry.concat(newRegistery1);


//--------------------------------------------------------------------------------------
// implement the function
// This draw the chart : for each date, we display the price of every asset
function drawPricesHistoryChart(priceHistoryData) 
{
	var pricesdata = new google.visualization.DataTable();
	pricesdata.addColumn('string', 'time');
	var nDates0 = priceHistoryData.datesList.length;
	var nAssets = priceHistoryData.datesList[0].assetsList.length;
	for( var asset = 0; asset < nAssets; asset++ )
    {
        pricesdata.addColumn('number', priceHistoryData.datesList[0].assetsList[asset].name);
    }

	pricesdata.addRows(nDates0);
    for( var date = 0; date < nDates0; date++ )
    {
        pricesdata.setValue(date, 0, priceHistoryData.datesList[date].time);
        for( var asset = 0; asset < nAssets; asset++ )
        {
            pricesdata.setValue(date, asset+1, priceHistoryData.datesList[date].assetsList[asset].price);
        }
    }

    var priceschart = new google.visualization.LineChart(document.getElementById('priceschart_div'));
	priceschart.draw(pricesdata, 
	   {
	    width: 600,
	    height: 300,
	    title: 'Prices History',
	    curveType:'function',
	    lineWidth:1,
	    pointSize:1
	    });
};